{# 以下是分页  #}
<div>
    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li class="disabled">
                <span>每页显示</span>
            </li>
            <li>
                            <span>
                                <select class="line_count" id="line_set" line_count={{ line_count }}  name="line_count">
                                    <option>5</option>
                                    <option>10</option>
                                    <option>15</option>
                                    <option>20</option>
                                </select>
                            </span>
            </li>

            <li>
                <a href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page=1&line_count={{ line_count }}&user_search={{ search }}"
                   aria-label="Previous">
                    <span aria-hidden="true">第一页</span>
                </a>
            </li>

            {% if current_page.has_previous %}
                <li>
                    <a href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page={{ current_page.previous_page_number }}&line_count={{ line_count }}&user_search={{ search }}"
                       aria-label="Previous">
                        <span aria-hidden="true">上一页</span>
                    </a>
                </li>
            {% else %}
                <li class="disabled">
                    <a href="" aria-label="Previous">
                        <span aria-hidden="true">上一页</span>
                    </a>
                </li>
            {% endif %}
            {# 拿到页码书总列表 #}
            {% for item in  page_range %}
                {% if current_page_num == item %}
                    <li class="active"><a
                            href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page={{ item }}&line_count={{ line_count }}&user_search={{ search }}">{{ item }}</a>
                    </li>
                {% else %}
                    <li>
                        <a href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page={{ item }}&line_count={{ line_count }}&user_search={{ search }}">{{ item }}</a>
                    </li>
                {% endif %}
            {% endfor %}

            {% if current_page.has_next %}
                <li>
                    <a href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page={{ current_page.next_page_number }}&line_count={{ line_count }}&user_search={{ search }}"
                       aria-label="Next">
                        <span aria-hidden="true">下一页</span>
                    </a>
                </li>
            {% else %}
                <li class="disabled">
                    <a href="" aria-label="Previous">
                        <span aria-hidden="true">下一页</span>
                    </a>
                </li>
            {% endif %}
            <li>
                <a href="{{ request.path }}?ins_type={{ ins_type }}&ins_status={{ ins_status }}&page={{ last_page }}&line_count={{ line_count }}&user_search={{ search }}"
                   aria-label="Previous">
                    <span aria-hidden="true">最后一页</span>
                </a>
            </li>
            <li class="disabled">
                <span>跳转到</span>
            </li>
            <li>
                                <span>
                                    <select id="page_set" page_set= {{ current_page_num }}>
                                      {% for   i  in paginator_num_pages_list %}
                                          <option>{{ i }}</option>);
                                      {% endfor %}
                                    </select>
                                </span>

            </li>

            <li class="disabled">
                <a href="" aria-label="Previous">
                    <span aria-hidden="true">共 {{ paginator.num_pages }} 页 , {{ paginator.count }} 条 </span>
                </a>
            </li>
        </ul>
    </nav>
</div>
{#  以上是分页 #}
{% block script %}
    <script>
        function getBaseQueryParams() {
            return new URLSearchParams({
                ins_type: $('#ins_type').val(),
                ins_status: $('#ins_status').val(),
                user_search: $('.aa_search').val(),
                line_count: $('#line_set').val(),
            });
        }

        $("#line_set").change(function () {
            let params = getBaseQueryParams();
            params.set('page', 1);  // 切换条数后重置页码为 1
            window.location.href = window.location.pathname + '?' + params.toString();
        });

        $("#page_set").change(function () {
            let params = getBaseQueryParams();
            params.set('page', $('#page_set').val());
            window.location.href = window.location.pathname + '?' + params.toString();
        });


    </script>


{% endblock %}

